
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Karthik T
 */
public class inGameMenu implements CommandListener {

    private MobilePong parent;
    private MainGame game;
    
    
    //TODO figureout the positioning issue
    private Command exit = new Command("Exit Game", Command.BACK, 99);
    private Command exitMenu = new Command("Exit To Main Menu", Command.BACK, 90);
    private Command audioOff = new Command("Audio Off", Command.BACK,85);
    private Command audioOn = new Command("Audio On", Command.BACK, 85);

    public inGameMenu(MobilePong parent) {
        this.parent=parent;
    }    
    
    public void addCommands(MainGame game){
        this.game=game;
        game.addCommand(exit);
        game.addCommand(exitMenu);
        if (audio.mode)
            game.addCommand(audioOff);
        else if (!audio.mode)
            game.addCommand(audioOn);
        game.setCommandListener(this);
    }    

    public void commandAction(Command c, Displayable d) {
        if (c == exit){
            parent.exitGame();
            parent.stopGame();
        }
        if(c==audioOff){
            game.Audio.setMode(false);
            game.addCommand(audioOn);
            game.removeCommand(c);
        }
        if(c==audioOn){
            game.Audio.setMode(true);
            game.addCommand(audioOff);
            game.removeCommand(c);
        }
        if(c==exitMenu){
            parent.stopGame();
            parent.startMenu();
            
        }
    }
}
